home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 2 / LSD and 17bit Compendium Deluxe - Volume II.iso / a / prog / amigae / gencodee_v22.lha / GenCodeE / sources / GenCodeE_v17 / GUIFile.e < prev    next >
Encoding:
Text File  |  1994-11-22  |  28.6 KB  |  1,194 lines

  1. OPT MODULE
  2. OPT LARGE
  3.  
  4.  
  5. ->*****
  6. ->** External modules
  7. ->*****
  8. MODULE 'muibuilder' , 'libraries/muibuilder'
  9.  
  10. MODULE '*Variable'
  11. MODULE '*AuxProcs'
  12.  
  13.  
  14. ->*****
  15. ->** Exception handling
  16. ->*****
  17. RAISE    "OPEN"    IF    Open()        =    NIL    ,
  18.         "OUT"    IF    Fputs()        =    -1    ,
  19.         "OUT"    IF    FputC()        =    -1    ,
  20.         "MEM"    IF    String()    =    NIL
  21.  
  22.  
  23. ->*****
  24. ->** Object definitions
  25. ->*****
  26. EXPORT    OBJECT gui_file
  27.             PRIVATE
  28.                 file                :    LONG
  29.                 number_vars            :    LONG
  30.                 vars                :    PTR TO variable
  31.                 ident_length_max    :    LONG
  32.                 hook_funcs            :    LONG
  33.                 main_object_ident    :    PTR TO CHAR
  34.         ENDOBJECT
  35.  
  36.  
  37. /***********************************
  38. ** Opens the GUI file to generate **
  39. ***********************************/
  40. PROC open( filename : PTR TO CHAR , number_vars , vars : PTR TO variable , ident_length_max ) OF gui_file
  41.  
  42.     DEF i
  43.  
  44.     self.file := Open( filename , NEWFILE )
  45.     self.number_vars := number_vars
  46.     self.vars := vars
  47.     self.ident_length_max := ident_length_max
  48.     self.main_object_ident := vars[ 0 ].ident
  49.     self.hook_funcs := FALSE
  50.  
  51.     FOR i := 0 TO ( number_vars - 1 ) DO IF vars[ i ].type = TYPEVAR_HOOK THEN self.hook_funcs := TRUE
  52.  
  53. ENDPROC
  54.  
  55.  
  56. /************************************
  57. ** Closes the GUI file to generate **
  58. ************************************/
  59. PROC close() OF gui_file
  60.  
  61.     IF self.file THEN Close( self.file )
  62.  
  63. ENDPROC
  64.  
  65.  
  66. /******************************************
  67. ** Write to the GUI file its header part **
  68. ******************************************/
  69. PROC put_header( application ) OF gui_file
  70.  
  71.     Fputs( self.file , '/* ////////////////////////////////////////////////////////////////////////////\n' )
  72.     Fputs( self.file , '//////////////////////////////////////////////////////// External modules /////\n' )
  73.     Fputs( self.file , '//////////////////////////////////////////////////////////////////////////// */\n' )
  74.     Fputs( self.file , 'MODULE ''muimaster'' , ''libraries/mui''\n' )
  75.     Fputs( self.file , 'MODULE ''intuition/classes'', ''intuition/classusr''\n' )
  76.     Fputs( self.file , 'MODULE ''utility/tagitem''' )
  77.  
  78.     Fputs( self.file , IF ( self.hook_funcs OR application ) THEN ' , ''utility/hooks''\n\n\n' ELSE '\n\n\n' )
  79.  
  80. ENDPROC
  81.  
  82.  
  83. /*********************************************************
  84. ** Write to the GUI file the definitions of aux objects **
  85. *********************************************************/
  86. PROC put_aux_objects( environment , application ) OF gui_file
  87.  
  88.     DEF i
  89.  
  90.     IF environment
  91.  
  92.         Fputs( self.file , '/* ////////////////////////////////////////////////////////////////////////////\n' )
  93.         Fputs( self.file , '////////////////////////////////////////////////////// Object definitions /////\n' )
  94.         Fputs( self.file , '//////////////////////////////////////////////////////////////////////////// */\n' )
  95.  
  96.         IF application
  97.  
  98.             Fputs( self.file , 'OBJECT app_arexx\n' )
  99.             Fputs( self.file , '\tcommands :\tLONG\n' )
  100.             Fputs( self.file , '\terror    :\thook\n' )
  101.             Fputs( self.file , 'ENDOBJECT\n\n' )
  102.  
  103.         ENDIF
  104.  
  105.     ENDIF
  106.  
  107.     IF self.hook_funcs
  108.  
  109.         IF environment
  110.  
  111.             Fputs( self.file , 'OBJECT ' )
  112.             Fputs( self.file , self.main_object_ident )
  113.             Fputs( self.file , '_display\n' )
  114.  
  115.         ENDIF
  116.  
  117.         FOR i := 0 TO ( self.number_vars - 1 )
  118.  
  119.             IF self.vars[ i ].type = TYPEVAR_HOOK
  120.  
  121.                 FputC( self.file , "\t" )
  122.                 Fputs( self.file , self.vars[ i ].ident )
  123.                 indent_defs( self.file , self.vars[ i ].ident , self.ident_length_max )
  124.                 Fputs( self.file , ' :\thook\n' )
  125.  
  126.             ENDIF
  127.  
  128.         ENDFOR
  129.  
  130.         IF environment THEN Fputs( self.file , 'ENDOBJECT\n\n' ) ELSE FputC( self.file , "\n" )
  131.  
  132.     ENDIF
  133.  
  134. ENDPROC
  135.  
  136.  
  137. /*****************************************************************
  138. ** Write to the GUI file the definition of the generated object **
  139. *****************************************************************/
  140. PROC put_main_object( environment ) OF gui_file
  141.  
  142.     DEF i
  143.  
  144.     IF environment
  145.  
  146.         Fputs( self.file , 'OBJECT ' )
  147.         Fputs( self.file , self.main_object_ident )
  148.         Fputs( self.file , '_obj\n' )
  149.  
  150.     ENDIF
  151.  
  152.     FOR i := 0 TO ( self.number_vars - 1 )
  153.  
  154.         IF self.vars[ i ].type = TYPEVAR_PTR
  155.  
  156.             FputC( self.file , "\t" )
  157.             Fputs( self.file , self.vars[ i ].ident )
  158.             indent_defs( self.file , self.vars[ i ].ident , self.ident_length_max )
  159.             Fputs( self.file , ' :\tLONG\n' )
  160.  
  161.         ENDIF
  162.  
  163.     ENDFOR
  164.  
  165.     FOR i := 0 TO ( self.number_vars - 1 )
  166.  
  167.         IF ( self.vars[ i ].type = TYPEVAR_INT ) AND ( self.vars[ i ].type = TYPEVAR_BOOL )
  168.  
  169.             FputC( self.file , "\t" )
  170.             Fputs( self.file , self.vars[ i ].ident )
  171.             indent_defs( self.file , self.vars[ i ].ident , self.ident_length_max )
  172.             Fputs( self.file , ' :\tLONG\n' )
  173.  
  174.         ENDIF
  175.  
  176.     ENDFOR
  177.  
  178.     FOR i := 0 TO ( self.number_vars - 1 )
  179.  
  180.         IF self.vars[ i ].type = TYPEVAR_STRING
  181.  
  182.             FputC( self.file , "\t" )
  183.             Fputs( self.file , self.vars[ i ].ident )
  184.             indent_defs( self.file , self.vars[ i ].ident , self.ident_length_max )
  185.             Fputs( self.file , ' :\tLONG\n' )
  186.  
  187.         ENDIF
  188.  
  189.     ENDFOR
  190.  
  191.     FOR i := 0 TO ( self.number_vars - 1 )
  192.  
  193.         IF self.vars[ i ].type = TYPEVAR_TABSTRING
  194.  
  195.             FputC( self.file , "\t" )
  196.             Fputs( self.file , self.vars[ i ].ident )
  197.             indent_defs( self.file , self.vars[ i ].ident , self.ident_length_max )
  198.             Fputs( self.file , ' :\tLONG\n' )
  199.  
  200.         ENDIF
  201.  
  202.     ENDFOR
  203.  
  204.     Fputs( self.file , IF environment THEN 'ENDOBJECT\n\n\n' ELSE '\n\n' )
  205.  
  206. ENDPROC
  207.  
  208.  
  209. /***********************************************************************************
  210. ** Write to the GUI file the definitions of the constants used with MUIM_ReturnID **
  211. ***********************************************************************************/
  212. PROC put_constants( environment ) OF gui_file
  213.  
  214.     DEF i , first_constant = TRUE , previous_ident : PTR TO CHAR , offset = 0
  215.  
  216.     FOR i := 0 TO ( self.number_vars - 1 )
  217.  
  218.         IF self.vars[ i ].type = TYPEVAR_IDENT
  219.  
  220.             IF first_constant
  221.  
  222.                 IF environment
  223.  
  224.                     Fputs( self.file , '/* ////////////////////////////////////////////////////////////////////////////\n' )
  225.                     Fputs( self.file , '//////////////////////////////////////////////////// Constant definitions /////\n' )
  226.                     Fputs( self.file , '//////////////////////////////////////////////////////////////////////////// */\n' )
  227.                     Fputs( self.file , 'ENUM ' )
  228.  
  229.                 ENDIF
  230.  
  231.                 Fputs( self.file , self.vars[ i ].ident )
  232.                 Fputs( self.file , ' = 1' )
  233.                 previous_ident := self.vars[ i ].ident
  234.                 first_constant := FALSE
  235.  
  236.             ELSE
  237.  
  238.                 indent_defs( self.file , previous_ident , self.ident_length_max + offset )
  239.                 Fputs( self.file , ' ,\n     ' )
  240.                 Fputs( self.file , self.vars[ i ].ident )
  241.                 offset := 4
  242.                 previous_ident := self.vars[ i ].ident
  243.  
  244.             ENDIF
  245.  
  246.         ENDIF
  247.  
  248.     ENDFOR
  249.  
  250.     IF first_constant = FALSE THEN Fputs( self.file , '\n\n\n' )
  251.  
  252. ENDPROC
  253.  
  254.  
  255. /*************************************************************
  256. ** Write to the GUI file the declaration of create() method **
  257. *************************************************************/
  258. PROC put_create_declaration( application ) OF gui_file
  259.  
  260.     Fputs( self.file , '/* ////////////////////////////////////////////////////////////////////////////\n' )
  261.     Fputs( self.file , '///////////// Creates one instance of one object or the whole application /////\n' )
  262.     Fputs( self.file , '//////////////////////////////////////////////////////////////////////////// */\n' )
  263.     Fputs( self.file , 'PROC create_' )
  264.     Fputs( self.file , self.main_object_ident )
  265.     FputC( self.file , "(" )
  266.  
  267.     IF application
  268.  
  269.         IF self.hook_funcs
  270.  
  271.             Fputs( self.file , ' display : PTR TO ' )
  272.             Fputs( self.file , self.main_object_ident )
  273.             Fputs( self.file , '_display ,\n            ' )
  274.  
  275.         ENDIF
  276.  
  277.         Fputs( self.file , ' icon ,\n' )
  278.         Fputs( self.file , '             arexx : PTR TO app_arexx ,\n' )
  279.         Fputs( self.file , '             menu ' )
  280.  
  281.     ELSE
  282.  
  283.         IF self.hook_funcs
  284.  
  285.             Fputs( self.file , ' display : PTR TO ' )
  286.             Fputs( self.file , self.main_object_ident )
  287.             Fputs( self.file , '_display ' )
  288.  
  289.         ENDIF
  290.  
  291.     ENDIF
  292.  
  293.     Fputs( self.file , ')\n\n' )
  294.  
  295. ENDPROC
  296.  
  297.  
  298. /********************************************************************
  299. ** Write to the GUI file the local declarations of create() method **
  300. ********************************************************************/
  301. PROC put_create_local_defs() OF gui_file
  302.  
  303.     DEF i , defs_string[ 70 ] : STRING
  304.  
  305.     FOR i := 0 TO ( self.number_vars - 1 )
  306.  
  307.         IF self.vars[ i ].type = TYPEVAR_LOCAL_PTR
  308.  
  309.             IF ( EstrLen( defs_string ) + StrLen ( self.vars[ i ].ident ) ) <= 57
  310.  
  311.                 IF EstrLen( defs_string ) <> 0 THEN StrAdd( defs_string , ' , ' )
  312.                 StrAdd( defs_string , self.vars[ i ].ident )
  313.  
  314.             ELSE
  315.  
  316.                 Fputs( self.file, '\tDEF ' )
  317.                 Fputs( self.file, defs_string )
  318.                 FputC( self.file , "\n" )
  319.                 SetStr( defs_string , 0 )
  320.                 StrAdd( defs_string , self.vars[ i ].ident )
  321.  
  322.             ENDIF
  323.  
  324.         ENDIF
  325.             
  326.     ENDFOR
  327.  
  328.     IF EstrLen( defs_string ) <> 0
  329.  
  330.         Fputs( self.file , '\tDEF ' )
  331.         Fputs( self.file , defs_string )
  332.         FputC( self.file , "\n" )
  333.  
  334.     ENDIF
  335.  
  336.     Fputs( self.file , '\tDEF tmp_object : PTR TO ' )
  337.     Fputs( self.file , self.main_object_ident )
  338.     Fputs( self.file , '_obj\n\n' )
  339.  
  340. ENDPROC
  341.  
  342.  
  343. /********************************************************************
  344. ** Write to the GUI file the local declarations of create() method **
  345. ********************************************************************/
  346. PROC put_create_initialisations( locale , getstring_func : PTR TO CHAR ) OF gui_file
  347.  
  348.     DEF i , j , initialisations = FALSE
  349.     DEF strptr : PTR TO CHAR
  350.  
  351.     Fputs( self.file , '\tIF ( tmp_object := New( SIZEOF ' )
  352.     Fputs( self.file , self.main_object_ident )
  353.     Fputs( self.file , '_obj ) ) = NIL THEN RETURN NIL\n\n' )
  354.  
  355.     FOR i := 0 TO ( self.number_vars - 1 )
  356.  
  357.         IF self.vars[ i ].type =TYPEVAR_STRING
  358.  
  359.             initialisations := TRUE
  360.  
  361.             Fputs( self.file , '\ttmp_object.' )
  362.             Fputs( self.file , self.vars[ i ].ident )
  363.             indent_defs( self.file , self.vars[ i ].ident , self.ident_length_max )
  364.             Fputs( self.file , ' := ' )
  365.  
  366.             IF Char( self.vars[ i ].init ) <> 0
  367.  
  368.                 IF locale
  369.  
  370.                     Fputs( self.file , getstring_func )
  371.                     Fputs( self.file , '( ' )
  372.                     Fputs( self.file , self.vars[ i ].init )
  373.                     Fputs( self.file , ' )\n' )
  374.  
  375.                 ELSE
  376.  
  377.                     Fputs( self.file , string_convert( self.vars[ i ].init ) )
  378.                     FputC( self.file , "\n" )
  379.  
  380.                 ENDIF
  381.  
  382.             ELSE
  383.  
  384.                 Fputs( self.file , 'NIL\n' )
  385.  
  386.             ENDIF
  387.  
  388.         ENDIF
  389.  
  390.     ENDFOR
  391.  
  392.     FOR i := 0 TO ( self.number_vars - 1 )
  393.  
  394.         IF self.vars[ i ].type = TYPEVAR_TABSTRING
  395.  
  396.             initialisations := TRUE
  397.  
  398.             Fputs( self.file , '\ttmp_object.' )
  399.             Fputs( self.file , self.vars[ i ].ident )
  400.             indent_defs( self.file , self.vars[ i ].ident , self.ident_length_max )
  401.             Fputs( self.file , ' := [ ' )
  402.             strptr := self.vars[ i ].init
  403.  
  404.             FOR j := 1 TO self.vars[ i ].size
  405.  
  406.                 IF locale
  407.  
  408.                     Fputs( self.file , getstring_func )
  409.                     Fputs( self.file , '( ' )
  410.                     Fputs( self.file , strptr )
  411.                     Fputs( self.file , ' ) ,\n\t\t' )
  412.  
  413.                 ELSE
  414.  
  415.                     Fputs( self.file , string_convert( strptr ) )
  416.                     Fputs( self.file , ' ,\n\t\t' )
  417.  
  418.                 ENDIF
  419.  
  420.                 strptr := strptr + StrLen( strptr ) + 1
  421.  
  422.             ENDFOR
  423.  
  424.             Fputs( self.file , 'NIL ]\n' )
  425.  
  426.         ENDIF
  427.  
  428.     ENDFOR
  429.  
  430.     IF initialisations THEN FputC( self.file , "\n" )
  431.  
  432. ENDPROC
  433.  
  434.  
  435. /************************************************
  436. ** Write to the GUI file all the creating code **
  437. ************************************************/
  438. PROC put_code( getstring_func : PTR TO CHAR , muistrings : PTR TO LONG ) OF gui_file
  439.  
  440.     DEF type , code
  441.     DEF indent_level = 1 , func_level = 0
  442.     DEF return = TRUE , objfunction = FALSE , inobj = FALSE
  443.  
  444.     Mb_GetNextCode( {type} , {code} )
  445.  
  446.     WHILE type <> -1
  447.  
  448.         SELECT type
  449.  
  450.             CASE TC_CREATEOBJ
  451.  
  452.                 indent_code( self.file , indent_level , return )
  453.                 Fputs( self.file , muistrings[ Val( code ) ] )
  454.                 Fputs( self.file , ' ,\n' )
  455.                 INC indent_level
  456.                 return := TRUE
  457.                 inobj := TRUE
  458.  
  459.                 IF Val( code ) = 113
  460.  
  461.                     indent_code( self.file , indent_level , return )
  462.                     Fputs( self.file , '( IF icon THEN MUIA_Application_DiskObject ELSE TAG_IGNORE ) , icon ,\n' )
  463.  
  464.                     indent_code( self.file , indent_level , return )
  465.                     Fputs( self.file , '( IF arexx THEN MUIA_Application_Commands ELSE TAG_IGNORE ) , ( IF arexx THEN arexx.commands ELSE NIL ) ,\n' )
  466.  
  467.                     indent_code( self.file , indent_level , return )
  468.                     Fputs( self.file , '( IF arexx THEN MUIA_Application_RexxHook ELSE TAG_IGNORE ) , ( IF arexx THEN arexx.error ELSE NIL ) ,\n' )
  469.  
  470.                     indent_code( self.file , indent_level , return )
  471.                     Fputs( self.file , '( IF menu THEN MUIA_Application_Menu ELSE TAG_IGNORE ) , menu ,\n' )
  472.  
  473.                 ENDIF
  474.  
  475.                 Mb_GetNextCode( {type} , {code} )
  476.  
  477.             CASE TC_ATTRIBUT
  478.  
  479.                 indent_code( self.file , indent_level , return )
  480.                 Fputs( self.file , muistrings[ Val( code ) ] )
  481.                 Fputs( self.file , ' , ')
  482.                 return := FALSE
  483.                 Mb_GetNextCode( {type} , {code} )
  484.  
  485.             CASE TC_END
  486.  
  487.                 DEC indent_level
  488.                 indent_code( self.file , indent_level , return )
  489.                 Fputs( self.file , muistrings[ Val( code ) ] )
  490.                 Fputs( self.file , '\n\n')
  491.                 inobj := FALSE
  492.                 return := TRUE
  493.                 Mb_GetNextCode( {type} , {code} )
  494.  
  495.             CASE TC_FUNCTION
  496.  
  497.                 indent_code( self.file , indent_level , return )
  498.  
  499.                 IF Val( code ) = 673
  500.  
  501.                     FputC( self.file , 34 )
  502.                     Mb_GetNextCode( {type} , {code} )
  503.                     Fputs( self.file , code )
  504.                     Mb_GetNextCode( {type} , {code} )
  505.                     Fputs( self.file , code )
  506.                     Mb_GetNextCode( {type} , {code} )
  507.                     Fputs( self.file , code )
  508.                     Mb_GetNextCode( {type} , {code} )
  509.                     Fputs( self.file , code )
  510.                     Mb_GetNextCode( {type} , {code} )
  511.                     Fputs( self.file , '" ,\n' )
  512.  
  513.                     return := TRUE
  514.  
  515.                 ELSE
  516.  
  517.                     INC func_level
  518.                     Fputs( self.file , muistrings[ Val( code ) ] )
  519.                     Fputs( self.file , '( ' )
  520.                     return := FALSE
  521.  
  522.                 ENDIF
  523.  
  524.                 Mb_GetNextCode( {type} , {code} )
  525.  
  526.             CASE TC_MUIARG_FUNCTION        ->    same as TC_FUNCTION
  527.  
  528.                 indent_code( self.file , indent_level , return )
  529.                 INC func_level
  530.                 Fputs( self.file , muistrings[ Val( code ) ] )
  531.                 Fputs( self.file , '( ' )
  532.                 return := FALSE
  533.                 Mb_GetNextCode( {type} , {code} )
  534.  
  535.             CASE TC_OBJFUNCTION
  536.  
  537.                 indent_code( self.file , indent_level , return )
  538.                 Fputs( self.file , muistrings[ Val( code ) ] )
  539.                 Fputs( self.file , '( ' )
  540.                 INC func_level
  541.                 return := FALSE
  542.                 objfunction := TRUE
  543.                 Mb_GetNextCode( {type} , {code} )
  544.  
  545.             CASE TC_MUIARG_OBJFUNCTION        ->    same as TC_OBJFUNCTION
  546.  
  547.                 indent_code( self.file , indent_level , return )
  548.                 Fputs( self.file , muistrings[ Val( code ) ] )
  549.                 Fputs( self.file , '( ' )
  550.                 INC func_level
  551.                 return := FALSE
  552.                 objfunction := TRUE
  553.                 Mb_GetNextCode( {type} , {code} )
  554.  
  555.             CASE TC_STRING
  556.  
  557.                 indent_code( self.file , indent_level , return )
  558.                 Fputs( self.file , string_convert( code ) )
  559.                 Mb_GetNextCode( {type} , {code} )
  560.  
  561.                 IF func_level > 0
  562.  
  563.                     IF type <> TC_END_FUNCTION THEN Fputs( self.file , ' , ' )
  564.                     return := FALSE
  565.  
  566.                 ELSE
  567.  
  568.                     Fputs( self.file , ' ,\n' )
  569.                     return := TRUE
  570.  
  571.                 ENDIF
  572.  
  573.             CASE TC_INTEGER
  574.  
  575.                 indent_code( self.file , indent_level , return )
  576.                 Fputs( self.file , code )
  577.                 Mb_GetNextCode( {type} , {code} )
  578.  
  579.                 IF func_level > 0
  580.  
  581.                     IF type <> TC_END_FUNCTION THEN Fputs( self.file , ' , ' )
  582.                     return := FALSE
  583.  
  584.                 ELSE
  585.  
  586.                     Fputs( self.file , ' ,\n' )
  587.                     return := TRUE
  588.  
  589.                 ENDIF
  590.  
  591.             CASE TC_CHAR
  592.  
  593.                 indent_code( self.file , indent_level , return )
  594.                 FputC( self.file , 34 )
  595.                 Fputs( self.file , code )
  596.                 Mb_GetNextCode( {type} , {code} )
  597.  
  598.                 IF func_level > 0
  599.  
  600.                     IF type <> TC_END_FUNCTION THEN Fputs( self.file , '" , ') ELSE FputC( self.file , 34 )
  601.                     return := FALSE
  602.  
  603.                 ELSE
  604.  
  605.                     Fputs( self.file , '" ,\n' )
  606.                     return := TRUE
  607.  
  608.                 ENDIF
  609.  
  610.             CASE TC_VAR_AFFECT
  611.  
  612.                 indent_code( self.file , indent_level , return )
  613.  
  614.                 IF self.vars[ Val( code ) ].type <> TYPEVAR_LOCAL_PTR
  615.  
  616.                     Fputs( self.file , 'tmp_object.' )
  617.  
  618.                 ENDIF
  619.  
  620.                 Fputs( self.file , self.vars[ Val( code ) ].ident )
  621.                 Fputs( self.file , ' := ')
  622.                 return := FALSE
  623.                 Mb_GetNextCode( {type} , {code} )
  624.  
  625.             CASE TC_VAR_ARG
  626.  
  627.                 indent_code( self.file , indent_level , return )
  628.  
  629.                 IF self.vars[ Val( code ) ].type <> TYPEVAR_LOCAL_PTR
  630.  
  631.                     Fputs( self.file , 'tmp_object.' )
  632.  
  633.                 ENDIF
  634.  
  635.                 Fputs( self.file , self.vars[ Val( code ) ].ident )
  636.                 Mb_GetNextCode( {type} , {code} )
  637.  
  638.                 IF func_level > 0
  639.  
  640.                     IF type <> TC_END_FUNCTION THEN Fputs( self.file , ' , ')
  641.                     return := FALSE
  642.  
  643.                 ELSE
  644.  
  645.                     Fputs( self.file , ' ,\n')
  646.                     return := TRUE
  647.  
  648.                 ENDIF
  649.  
  650.             CASE TC_OBJ_ARG        ->    same as TC_VAR_ARG
  651.  
  652.                 indent_code( self.file , indent_level , return )
  653.  
  654.                 IF self.vars[ Val( code ) ].type <> TYPEVAR_LOCAL_PTR
  655.  
  656.                     Fputs( self.file , 'tmp_object.' )
  657.  
  658.                 ENDIF
  659.  
  660.                 Fputs( self.file , self.vars[ Val( code ) ].ident )
  661.                 Mb_GetNextCode( {type} , {code} )
  662.  
  663.                 IF func_level > 0
  664.  
  665.                     IF type <> TC_END_FUNCTION THEN Fputs( self.file , ' , ')
  666.                     return := FALSE
  667.  
  668.                 ELSE
  669.  
  670.                     Fputs( self.file , ' ,\n')
  671.                     return := TRUE
  672.  
  673.                 ENDIF
  674.  
  675.             CASE TC_END_FUNCTION
  676.  
  677.                 indent_code( self.file , indent_level , return )
  678.                 DEC func_level
  679.                 Mb_GetNextCode( {type} , {code} )
  680.  
  681.                 IF func_level > 0
  682.  
  683.                     Fputs( self.file , ' )' )
  684.                     IF type <> TC_END_FUNCTION THEN Fputs( self.file , ' ,' )
  685.                     return := FALSE
  686.  
  687.                 ELSE
  688.  
  689.                     Fputs( self.file , IF objfunction THEN ' )\n\n' ELSE ' ) ,\n' )
  690.                     objfunction := FALSE
  691.                     return := TRUE
  692.  
  693.                 ENDIF
  694.  
  695.             CASE TC_BOOL
  696.  
  697.                 indent_code( self.file , indent_level , return )
  698.                 Fputs( self.file , IF Char( code ) = "0" THEN 'FALSE' ELSE 'MUI_TRUE')
  699.                 Mb_GetNextCode( {type} , {code} )
  700.  
  701.                 IF func_level > 0
  702.  
  703.                     IF type <> TC_END_FUNCTION THEN Fputs( self.file , ' , ')
  704.                     return := FALSE
  705.  
  706.                 ELSE
  707.  
  708.                     Fputs( self.file , ' ,\n')
  709.                     return := TRUE
  710.  
  711.                 ENDIF
  712.  
  713.             CASE TC_MUIARG
  714.  
  715.                 indent_code( self.file , indent_level , return )
  716.                 Fputs( self.file , muistrings[ Val( code ) ] )
  717.                 Mb_GetNextCode( {type} , {code} )
  718.  
  719.                 IF func_level > 0
  720.  
  721.                     IF type <> TC_END_FUNCTION THEN Fputs( self.file , ' , ')
  722.                     return := FALSE
  723.  
  724.                 ELSE
  725.  
  726.                     Fputs( self.file , ' ,\n')
  727.                     return := TRUE
  728.  
  729.                 ENDIF
  730.  
  731.             CASE TC_MUIARG_OBJ
  732.  
  733.                 indent_code( self.file , indent_level , return )
  734.                 Fputs( self.file , muistrings[ Val( code ) ] )
  735.                 Mb_GetNextCode( {type} , {code} )
  736.  
  737.                 IF inobj
  738.  
  739.                     Fputs( self.file , ' ,\n' )
  740.                     return := TRUE
  741.  
  742.                 ELSE
  743.  
  744.                     IF func_level > 0
  745.  
  746.                         IF type <> TC_END_FUNCTION THEN Fputs( self.file , ' , ')
  747.                         return := FALSE
  748.  
  749.                     ELSE
  750.  
  751.                         Fputs( self.file , '\n\n')
  752.                         return := TRUE
  753.  
  754.                     ENDIF
  755.  
  756.                 ENDIF
  757.  
  758.             CASE TC_MUIARG_ATTRIBUT        ->    same as TC_MUIARG_OBJ
  759.  
  760.                 indent_code( self.file , indent_level , return )
  761.                 Fputs( self.file , muistrings[ Val( code ) ] )
  762.                 Mb_GetNextCode( {type} , {code} )
  763.  
  764.                 IF inobj
  765.  
  766.                     Fputs( self.file , ' ,\n' )
  767.                     return := TRUE
  768.  
  769.                 ELSE
  770.  
  771.                     IF func_level > 0
  772.  
  773.                         IF type <> TC_END_FUNCTION THEN Fputs( self.file , ' , ')
  774.                         return := FALSE
  775.  
  776.                     ELSE
  777.  
  778.                         Fputs( self.file , '\n\n')
  779.                         return := TRUE
  780.  
  781.                     ENDIF
  782.  
  783.                 ENDIF
  784.  
  785.             CASE TC_EXTERNAL_FUNCTION
  786.  
  787.                 indent_code( self.file , indent_level , return )
  788.                 Fputs( self.file , 'display.' )
  789.                 Fputs( self.file , code )
  790.                 Mb_GetNextCode( {type} , {code} )
  791.  
  792.                 IF func_level > 0
  793.  
  794.                     IF type <> TC_END_FUNCTION THEN Fputs( self.file , ' , ')
  795.                     return := FALSE
  796.  
  797.                 ELSE
  798.  
  799.                     Fputs( self.file , ' ,\n')
  800.                     return := TRUE
  801.  
  802.                 ENDIF
  803.  
  804.             CASE TC_LOCALESTRING
  805.  
  806.                 indent_code( self.file , indent_level , return )
  807.                 Fputs( self.file , 'getMBstring( ')
  808.                 Fputs( self.file ,  code )
  809.                 Fputs( self.file , ' )')
  810.                 Mb_GetNextCode( {type} , {code} )
  811.  
  812.                 IF func_level > 0
  813.  
  814.                     IF type<>TC_END_FUNCTION THEN Fputs( self.file , ' , ')
  815.                     return := FALSE
  816.  
  817.                 ELSE
  818.  
  819.                     Fputs( self.file , ' ,\n')
  820.                     return := TRUE
  821.  
  822.                 ENDIF
  823.  
  824.             CASE TC_LOCALECHAR
  825.  
  826.                 indent_code( self.file , indent_level , return )
  827.                 Fputs( self.file , 'Char( ' )
  828.                 Fputs( self.file , getstring_func )
  829.                 Fputs( self.file , '( ')
  830.                 Fputs( self.file ,  code )
  831.                 Fputs( self.file , ' ) )')
  832.                 Mb_GetNextCode( {type} , {code} )
  833.  
  834.                 IF func_level > 0
  835.  
  836.                     IF type<>TC_END_FUNCTION THEN Fputs( self.file , ' , ')
  837.                     return := FALSE
  838.  
  839.                 ELSE
  840.  
  841.                     Fputs( self.file , ' ,\n')
  842.                     return := TRUE
  843.  
  844.                 ENDIF
  845.  
  846.         ENDSELECT
  847.  
  848.     ENDWHILE
  849.  
  850. ENDPROC
  851.  
  852.  
  853. /*****************************************************
  854. ** Write to the GUI file the end of create() method **
  855. *****************************************************/
  856. PROC put_create_end() OF gui_file
  857.  
  858.     Fputs( self.file , '\tIF tmp_object.app = NIL\n' )
  859.     Fputs( self.file , '\t\tDispose( tmp_object )\n' )
  860.     Fputs( self.file , '\t\ttmp_object := NIL\n' )
  861.     Fputs( self.file , '\tENDIF\n\n' )
  862.     Fputs( self.file , 'ENDPROC tmp_object\n\n\n' )
  863.  
  864. ENDPROC
  865.  
  866.  
  867. /***********************************************
  868. ** Write to the GUI file the dispose() method **
  869. ***********************************************/
  870. PROC put_dispose_method() OF gui_file
  871.  
  872.     Fputs( self.file , '/* ////////////////////////////////////////////////////////////////////////////\n' )
  873.     Fputs( self.file , '//////////////////////////// Disposes the object or the whole application /////\n' )
  874.     Fputs( self.file , '//////////////////////////////////////////////////////////////////////////// */\n' )
  875.     Fputs( self.file , 'PROC dispose_' )
  876.     Fputs( self.file , self.main_object_ident )
  877.     Fputs( self.file , '( tmp_object : PTR TO ' )
  878.     Fputs( self.file , self.main_object_ident )
  879.     Fputs( self.file , '_obj )\n\n' )
  880.     Fputs( self.file , '\tIF tmp_object.app THEN Mui_DisposeObject( tmp_object.app )\n' )
  881.     Fputs( self.file , '\tDispose( tmp_object )\n\n' )
  882.     Fputs( self.file , 'ENDPROC\n\n\n' )
  883.  
  884. ENDPROC
  885.  
  886.  
  887. /*************************************************************************
  888. ** Write to the GUI file the declaration of init_notifications() method **
  889. *************************************************************************/
  890. PROC put_init_notifications_declaration() OF gui_file
  891.  
  892.     Fputs( self.file , '/* ////////////////////////////////////////////////////////////////////////////\n' )
  893.     Fputs( self.file , '///////////////////////// Initializes all the notifications of one object /////\n' )
  894.     Fputs( self.file , '///////////////////////////////////////////// or of the whole application /////\n' )
  895.     Fputs( self.file , '//////////////////////////////////////////////////////////////////////////// */\n' )
  896.     Fputs( self.file , 'PROC init_notifications_' )
  897.     Fputs( self.file , self.main_object_ident )
  898.     Fputs( self.file , '( tmp_object : PTR TO ' )
  899.     Fputs( self.file , self.main_object_ident )
  900.     Fputs( self.file , '_obj ' )
  901.  
  902.     IF self.hook_funcs
  903.  
  904.         Fputs( self.file , ', display : PTR TO ' )
  905.         Fputs( self.file , self.main_object_ident )
  906.         Fputs( self.file , '_display ' )
  907.  
  908.     ENDIF
  909.  
  910.     Fputs( self.file , ')\n\n' )
  911.  
  912. ENDPROC
  913.  
  914.  
  915. /************************************************
  916. ** Write to the GUI file all the notifications **
  917. ************************************************/
  918. PROC put_notifications( muistrings : PTR TO LONG ) OF gui_file
  919.  
  920.     DEF type , code , indent = FALSE
  921.  
  922.     Mb_GetNextNotify( {type} , {code} )
  923.  
  924.     WHILE ( type <> -1 )
  925.  
  926.         IF indent THEN Fputs( self.file , '\t\t' )
  927.  
  928.         SELECT type
  929.  
  930.             CASE TC_BEGIN_NOTIFICATION
  931.  
  932.                 Fputs( self.file , '\tdomethod( tmp_object.' )
  933.                 Fputs( self.file , self.vars[ Val( code ) ].ident )
  934.                 Fputs( self.file , ' ,\n\t\t[ ' )
  935.                 indent := FALSE
  936.                 Mb_GetNextNotify( {type} , {code} )
  937.  
  938.             CASE TC_END_NOTIFICATION
  939.  
  940.                 Fputs( self.file , ' ] )\n\n' )
  941.                 indent := FALSE
  942.                 Mb_GetNextNotify( {type} , {code} )
  943.  
  944.             CASE TC_FUNCTION
  945.  
  946.                 FputC( self.file , "\t" )
  947.                 Fputs( self.file , muistrings[ Val( code ) ] )
  948.                 Fputs( self.file , '( ' )
  949.                 indent := FALSE
  950.                 Mb_GetNextNotify( {type} , {code} )
  951.  
  952.             CASE TC_END_FUNCTION
  953.  
  954.                 Fputs( self.file , ' )\n\n' )
  955.                 indent := FALSE
  956.                 Mb_GetNextNotify( {type} , {code} )
  957.  
  958.             CASE TC_STRING
  959.  
  960.                 Fputs( self.file , string_convert( code ) )
  961.                 Mb_GetNextNotify( {type} , {code} )
  962.  
  963.                 IF ( type <> TC_END_FUNCTION ) AND ( type <> TC_END_NOTIFICATION )
  964.  
  965.                     indent := TRUE
  966.                     Fputs( self.file , ' ,\n' )
  967.  
  968.                 ELSE
  969.  
  970.                     indent := FALSE
  971.  
  972.                 ENDIF
  973.  
  974.             CASE TC_LOCALESTRING
  975.  
  976.                 Fputs( self.file , 'getMBstring( ')
  977.                 Fputs( self.file ,  code )
  978.                 Fputs( self.file , ' )')
  979.                 Mb_GetNextNotify( {type} , {code} )
  980.  
  981.                 IF ( type <> TC_END_FUNCTION ) AND ( type <> TC_END_NOTIFICATION )
  982.  
  983.                     indent := TRUE
  984.                     Fputs( self.file , ' ,\n' )
  985.  
  986.                 ELSE
  987.  
  988.                     indent := FALSE
  989.  
  990.                 ENDIF
  991.  
  992.  
  993.             CASE TC_INTEGER
  994.  
  995.                 Fputs( self.file , code )
  996.                 Mb_GetNextNotify( {type} , {code} )
  997.  
  998.                 IF ( type <> TC_END_FUNCTION ) AND ( type <> TC_END_NOTIFICATION )
  999.  
  1000.                     indent := TRUE
  1001.                     Fputs( self.file , ' ,\n' )
  1002.  
  1003.                 ELSE
  1004.  
  1005.                     indent := FALSE
  1006.  
  1007.                 ENDIF
  1008.  
  1009.  
  1010.             CASE TC_CHAR
  1011.  
  1012.                 FputC( self.file , 34)
  1013.                 Fputs( self.file , code )
  1014.                 FputC( self.file , 34)
  1015.                 Mb_GetNextNotify( {type} , {code} )
  1016.  
  1017.                 IF ( type <> TC_END_FUNCTION ) AND ( type <> TC_END_NOTIFICATION )
  1018.  
  1019.                     indent := TRUE
  1020.                     Fputs( self.file , ' ,\n' )
  1021.  
  1022.                 ELSE
  1023.  
  1024.                     indent := FALSE
  1025.  
  1026.                 ENDIF
  1027.  
  1028.             CASE TC_BOOL
  1029.  
  1030.                 Fputs( self.file , IF Char( code ) = "0" THEN 'FALSE' ELSE 'MUI_TRUE')
  1031.                 Mb_GetNextNotify( {type} , {code} )
  1032.  
  1033.                 IF ( type <> TC_END_FUNCTION ) AND ( type <> TC_END_NOTIFICATION )
  1034.  
  1035.                     indent := TRUE
  1036.                     Fputs( self.file , ' ,\n' )
  1037.  
  1038.                 ELSE
  1039.  
  1040.                     indent := FALSE
  1041.  
  1042.                 ENDIF
  1043.  
  1044.             CASE TC_VAR_ARG
  1045.  
  1046.                 Fputs( self.file , 'tmp_object.')
  1047.                 Fputs( self.file , self.vars[ Val( code ) ].ident )
  1048.                 Mb_GetNextNotify( {type} , {code} )
  1049.  
  1050.                 IF ( type <> TC_END_FUNCTION ) AND ( type <> TC_END_NOTIFICATION )
  1051.  
  1052.                     indent := TRUE
  1053.                     Fputs( self.file , ' ,\n' )
  1054.  
  1055.                 ELSE
  1056.  
  1057.                     indent := FALSE
  1058.  
  1059.                 ENDIF
  1060.  
  1061.             CASE TC_MUIARG
  1062.  
  1063.                 Fputs( self.file , muistrings[ Val( code ) ] )
  1064.                 indent := FALSE
  1065.                 Mb_GetNextNotify( {type} , {code} )
  1066.                 IF ( type <> TC_END_FUNCTION ) AND ( type <> TC_END_NOTIFICATION ) THEN Fputs( self.file , ' , ' )
  1067.  
  1068.             CASE TC_MUIARG_OBJ        ->    same as TC_MUIARG
  1069.  
  1070.                 Fputs( self.file , muistrings[ Val( code ) ] )
  1071.                 indent := FALSE
  1072.                 Mb_GetNextNotify( {type} , {code} )
  1073.                 IF ( type <> TC_END_FUNCTION ) AND ( type <> TC_END_NOTIFICATION ) THEN Fputs( self.file , ' , ' )
  1074.  
  1075.             CASE TC_MUIARG_ATTRIBUT
  1076.  
  1077.                 Fputs( self.file , muistrings[ Val( code ) ] )
  1078.                 Mb_GetNextNotify( {type} , {code} )
  1079.  
  1080.                 IF ( type <> TC_END_FUNCTION ) AND ( type <> TC_END_NOTIFICATION )
  1081.  
  1082.                     indent := TRUE
  1083.                     Fputs( self.file , ' ,\n' )
  1084.  
  1085.                 ELSE
  1086.  
  1087.                     indent := FALSE
  1088.  
  1089.                 ENDIF
  1090.  
  1091.             CASE TC_EXTERNAL_CONSTANT
  1092.  
  1093.                 Fputs( self.file , code )
  1094.                 Mb_GetNextNotify( {type} , {code} )
  1095.  
  1096.                 IF ( type <> TC_END_FUNCTION ) AND ( type <> TC_END_NOTIFICATION )
  1097.  
  1098.                     indent := TRUE
  1099.                     Fputs( self.file , ' ,\n' )
  1100.  
  1101.                 ELSE
  1102.  
  1103.                     indent := FALSE
  1104.  
  1105.                 ENDIF
  1106.  
  1107.  
  1108.             CASE TC_EXTERNAL_FUNCTION
  1109.  
  1110.                 Fputs( self.file , 'display.' )
  1111.                 Fputs( self.file , code )
  1112.                 Mb_GetNextNotify( {type} , {code} )
  1113.  
  1114.                 IF ( type <> TC_END_FUNCTION ) AND ( type <> TC_END_NOTIFICATION )
  1115.  
  1116.                     indent := TRUE
  1117.                     Fputs( self.file , ' ,\n' )
  1118.  
  1119.                 ELSE
  1120.  
  1121.                     indent := FALSE
  1122.  
  1123.                 ENDIF
  1124.  
  1125.  
  1126.             CASE TC_EXTERNAL_VARIABLE
  1127.  
  1128.                 Fputs( self.file , code )
  1129.                 Mb_GetNextNotify( {type} , {code} )
  1130.  
  1131.                 IF ( type <> TC_END_FUNCTION ) AND ( type <> TC_END_NOTIFICATION )
  1132.  
  1133.                     indent := TRUE
  1134.                     Fputs( self.file , ' ,\n' )
  1135.  
  1136.                 ELSE
  1137.  
  1138.                     indent := FALSE
  1139.  
  1140.                 ENDIF
  1141.  
  1142.         ENDSELECT
  1143.  
  1144.     ENDWHILE
  1145.  
  1146. ENDPROC
  1147.  
  1148.  
  1149. /*****************************************************************
  1150. ** Write to the GUI file the end of init_notifications() method **
  1151. *****************************************************************/
  1152. PROC put_init_notifications_end() OF gui_file IS Fputs( self.file , 'ENDPROC\n\n\n' )
  1153.  
  1154.  
  1155. /*************************************************
  1156. ** Write to the GUI file getMBstring() function **
  1157. *************************************************/
  1158. PROC put_aux_funcs( locale , getstring_func : PTR TO CHAR ) OF gui_file
  1159.  
  1160.     IF locale
  1161.  
  1162.         Fputs( self.file , '/* ////////////////////////////////////////////////////////////////////////////\n' )
  1163.         Fputs( self.file , '////////////// Special GetString() function for MUIBuilder generated code /////\n' )
  1164.         Fputs( self.file , '//////////////////////////////////////////////////////////////////////////// */\n' )
  1165.         Fputs( self.file , 'PROC getMBstring( string_reference )\n\n' )
  1166.         Fputs( self.file , '    DEF local_string\n\n' )
  1167.         Fputs( self.file , '    local_string := ' )
  1168.         Fputs( self.file , getstring_func )
  1169.         Fputs( self.file , '( string_reference )\n\n' )
  1170.         Fputs( self.file , 'ENDPROC ( IF local_string[ 1 ] = 0 THEN ( local_string + 2 ) ELSE local_string )\n\n\n' )
  1171.  
  1172.     ENDIF
  1173.  
  1174.     Fputs( self.file , '/* ////////////////////////////////////////////////////////////////////////////\n' )
  1175.     Fputs( self.file , '/////////////////////////////////////////////////////// domethod function /////\n' )
  1176.     Fputs( self.file , '//////////////////////////////////////////////////////////////////////////// */\n' )
  1177.     Fputs( self.file , 'PROC domethod( obj : PTR TO object , msg : PTR TO msg )\n\n' )
  1178.     Fputs( self.file , '\tDEF h : PTR TO hook , o : PTR TO object , dispatcher\n\n' )
  1179.     Fputs( self.file , '\tIF obj\n' )
  1180.     Fputs( self.file , '\t\to := obj-SIZEOF object\t\t/* instance data is to negative offset */\n' )
  1181.     Fputs( self.file , '\t\th := o.class\n' )
  1182.     Fputs( self.file , '\t\tdispatcher := h.entry\t\t/* get dispatcher from hook in iclass */\n' )
  1183.     Fputs( self.file , '\t\tMOVEA.L h,A0\n' )
  1184.     Fputs( self.file , '\t\tMOVEA.L msg,A1\n' )
  1185.     Fputs( self.file , '\t\tMOVEA.L obj,A2\t\t\t/* probably should use CallHookPkt, but the */\n' )
  1186.     Fputs( self.file , '\t\tMOVEA.L dispatcher,A3\t\t/*   original code (DoMethodA()) doesn''t. */\n' )
  1187.     Fputs( self.file , '\t\tJSR (A3)\t\t\t/* call classDispatcher() */\n' )
  1188.     Fputs( self.file , '\t\tMOVE.L D0,o\n' )
  1189.     Fputs( self.file , '\t\tRETURN o\n' )
  1190.     Fputs( self.file , '\tENDIF\n\n' )
  1191.     Fputs( self.file , 'ENDPROC NIL\n' )
  1192.  
  1193. ENDPROC
  1194.